import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

//复制粘贴视频
public class Homework {
	@SuppressWarnings("resource")
	public static void main(String[] args) throws Exception {
		//建立数据源与程序之间的通道
		File fileFrom = new File("D:/test1109/魂断蓝桥-1.mp4");
		//判断该文件是否存在
		if(fileFrom.exists()) {
			BufferedInputStream bis = new  BufferedInputStream(new FileInputStream(fileFrom));
			//写文件
			File fileTo = new File("魂断蓝桥-1.mp4");
			BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(fileTo));
			//用数组进行读写
			byte [] bs=new byte[1024];
			int len=-1;
			while((len=bis.read(bs))!=-1) {
				bos.write(bs, 0, len);
				bos.flush();
			}
			bos.close();
			bis.close();
			//判断文件是否复制成功
			if(fileTo.exists() && fileTo.length()==fileFrom.length()) {
				System.out.println("文件复制成功！");
			}else {
				System.out.println("文件复制失败！");
			}
		}else {
			System.out.println("文件不存在！");
		}
	}
}
